<!DOCTYPE html>
<html>
	<script type="text/javascript" src="json.js"></script>

	<head>
		<script type="text/javascript">
			function ArrayList() {
				this.arr = [],
					this.size = function() {
						return this.arr.length;
					},
					this.add = function() {
						if(arguments.length == 1) {
							this.arr.push(arguments[0]);
						} else if(arguments.length >= 2) {
							var deleteItem = this.arr[arguments[0]];
							this.arr.splice(arguments[0], 1, arguments[1], deleteItem)
						}
						return this;
					},
					this.get = function(index) {
						return this.arr[index];
					},
					this.removeIndex = function(index) {
						this.arr.splice(index, 1);
					},
					this.removeObj = function(obj) {
						this.removeIndex(this.indexOf(obj));
					},
					this.indexOf = function(obj) {
						for(var i = 0; i < this.arr.length; i++) {
							if(this.arr[i] === obj) {
								return i;
							};
						}
						return -1;
					},
					this.isEmpty = function() {
						return this.arr.length == 0;
					},
					this.clear = function() {
						this.arr = [];
					},
					this.contains = function(obj) {
						return this.indexOf(obj) != -1;
					}

			};

			//新建一个List 
			var list = new ArrayList();
			//增加一个元素 
//			list.add("0").add("1").add("2").add("3");
			//增加指定位置 
			list.add(0, "22222222222");
			list.add(2, "22222222222");
			list.add(2, "22222222222");
			//删除指定元素 
//			list.removeObj("3");
//			//删除指定位置元素 
//			list.removeIndex(0);

			for(var i = 0; i < list.size(); i++) {
				document.writeln(i+":"+list.get(i)+"</br>");
			}
//			document.writeln(list.contains("2"))
		</script>
	</head>

	<body>
	</body>

</html>